package chapter03

import org.apache.log4j.{Level, Logger}
import org.apache.spark.{SparkConf, SparkContext}

object Test18_doubleValue {
  def main(args: Array[String]): Unit = {
    val logger = Logger.getLogger("org.apache.spark")
    logger.setLevel(Level.WARN)
    val doubleValue = new SparkConf().setMaster("local[*]").setAppName("doubleValue")
    val sc = new SparkContext(doubleValue)
    val value = sc.makeRDD(List(1, 2, 3, 4, 5),3)
    val value1 = sc.makeRDD(List(3, 4, 5, 6, 7),3)
    //交集 两个集合的类型需要一致
    val value2 = value.intersection(value1)
    println(value2.collect().toList)
    //并集
    val value3 = value.union(value1)
    println(value3.collect().toList)
    //差集
    val value4 = value.subtract(value1)
    println(value4.collect().toList)
    //zip 元素个数一致 两个集合的分区个数相等 两个集合的类型可以不一致
    val value5 = value.zip(value1)
    println(value5.collect().toList)
  }
}
